<?php


namespace App\Logic;

use App\server\RedisServer;
use App\server\EsServer;
/**
 * 后台用户信息逻辑层
 * Class AdminLogic
 * @package App\Logic
 *  @ name:zf
 */
class SeachLogic{

    /**
     * 搜索信息存入ES
     */
    public static function SeachEsCreate($realeEstateList){

        foreach($realeEstateList['data'] as $v){

            (new EsServer())->EsAdd('Seach_index',$v);
        }
       return true;
    }
    /**
    * 搜索信息ES搜索
    */
    public static function SeachEsIndex($name){
        if(!empty($name)) $where=$name;
        $realeEstateData= (new EsServer())->searchEs('Seach_index',$where,'name');
        return $realeEstateData;
    }
    /**
     * 搜索排行榜
     */
    public static function seachRank(){
        $redis=RedisServer::createRedisObject();
        $redis->select(8);
        $key='week_rank';
       return $redis->zRevRange($key,0,9,true);
    }
    /**
     * 搜索列表
     */
    public static function seachList(){
       $key='search_index';
       return (new EsServer())->EsAll($key);
    }
    /**
     * 搜索信息存入ES
     */
    public static function SeachEsInsert($name){

        $index='search_index';
        $search=[
            'id'=>time(),
            'name'=>$name,
        ];
        (new EsServer())->EsAdd($index,$search);
    }

}
